From c0595fbca89a6b2efb075c8cc4b8cec3efe2fabe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 8 Oct 2015 21:30:33 -0700 Subject: [PATCH] Include filename in path fingerprint This helps diagnose "why did this rebuild" situations so not only the mtime is known but also the file in question. --- src/cargo/sources/path.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 60915a881..1da040f1a 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -1,4 +1,3 @@ -use std::cmp; use std::fmt::{self, Debug, Formatter}; use std::fs; use std::io::prelude::*; @@ -313,19 +312,23 @@ impl<'cfg> Source for PathSource<'cfg> { } let mut max = FileTime::zero(); - for file in try!(self.list_files(pkg)).iter() { + let mut max_path = PathBuf::from(""); + for file in try!(self.list_files(pkg)) { // An fs::stat error here is either because path is a // broken symlink, a permissions error, or a race // condition where this path was rm'ed - either way, // we can ignore the error and treat the path's mtime // as 0. - let mtime = fs::metadata(file).map(|meta| { + let mtime = fs::metadata(&file).map(|meta| { FileTime::from_last_modification_time(&meta) }).unwrap_or(FileTime::zero()); warn!("{} {}", mtime, file.display()); - max = cmp::max(max, mtime); + if mtime > max { + max = mtime; + max_path = file; + } } trace!("fingerprint {}: {}", self.path.display(), max); - Ok(max.to_string()) + Ok(format!("{} ({})", max, max_path.display())) } } -- 2.30.2